home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / doom / relwep12.zip / CBNMODS.QC next >
Text File  |  1996-08-20  |  7KB  |  198 lines

  1. /*-------------------------------------------------------------------
  2. Filename : cbnmods.qc
  3. Author   : Cameron Newham
  4. Version  : 1.2
  5. Date     : 96/08/20
  6.  
  7. Description
  8. -----------
  9. Provides routines specific to my patches.  See the description
  10. file that came with the archive for further details.
  11.  
  12. Public Entry Points
  13. -------------------
  14. CN_Missile_Bubbles
  15. CN_Missile_Think
  16. CN_Ditch_Rockets
  17. --------------------------------------------------------------------*/
  18.  
  19. void() bubble_bob;
  20. void() GrenadeExplode; //Needed for CN_Missile_Think
  21. void(float num_bubbles) DeathBubbles;
  22.  
  23. /*-------------------------------------------------------------------
  24. Slightly modified version of Id's DeathBubblesSpawn
  25. --------------------------------------------------------------------*/
  26. void() MissileBubblesSpawn =
  27. {
  28. local entity    bubble;
  29.         bubble = spawn();
  30.         setmodel (bubble, "progs/s_bubble.spr");
  31.         setorigin (bubble, self.owner.origin);
  32.         bubble.movetype = MOVETYPE_NOCLIP;
  33.         bubble.solid = SOLID_NOT;
  34.         bubble.velocity = '0 0 15';
  35.         bubble.nextthink = time + 0.5;
  36.         bubble.think = bubble_bob;
  37.         bubble.classname = "bubble";
  38.         bubble.frame = 0;
  39.         bubble.cnt = 0;
  40.         setsize (bubble, '-8 -8 -8', '8 8 8');
  41.         self.nextthink = time + 0.1;
  42.         self.think = MissileBubblesSpawn;
  43.         self.air_finished = self.air_finished + 1;
  44.         if (self.air_finished >= self.bubble_count)
  45.                 remove(self);
  46. };
  47.  
  48. /*---------------------CN_Missile_Bubbles----------------------------
  49. Makes an underwater entity look like a real underwater entity by
  50. spraying out bubbles.  This is designed for use with rockets.
  51. --------------------------------------------------------------------*/
  52. void(float num_bubbles) CN_Missile_Bubbles =
  53. {
  54.   local vector  rocket_origin;
  55.   local entity  bubble_spawner;
  56.         
  57.         //rocket_origin = self.origin + ('0 -50 -50');
  58.         bubble_spawner = spawn();
  59.         setorigin (bubble_spawner, self.origin + '0 0 -60');
  60.         bubble_spawner.movetype = MOVETYPE_NONE;
  61.         bubble_spawner.solid = SOLID_NOT;
  62.         bubble_spawner.nextthink = time + 0.1;
  63.         bubble_spawner.think = MissileBubblesSpawn;
  64.         bubble_spawner.air_finished = 0;
  65.         bubble_spawner.owner = self;
  66.         bubble_spawner.bubble_count = num_bubbles;
  67.         return;
  68. };
  69.  
  70.  
  71. /*----------------------CN_Missile_Think-----------------------------
  72. Missile Velocity Correction.
  73. Correct the velocity of spikes, rockets and grenades underwater.  
  74. Simulates water resistance.  Also calls CN_Missile_Bubbles for rockets
  75. underwater.  Rockets are slowed in water and speed up again in air,
  76. while grenades are slowed by each passage through water.
  77. --------------------------------------------------------------------*/
  78. void() CN_Missile_Think =
  79. {
  80.   local vector v1;
  81.   local vector v2;
  82.  
  83.   // if it's a grenade then we must make it explode after
  84.   // it's duration expires
  85.  
  86.   if ((self.classname == "grenade") && (time > self.duration))
  87.   {
  88.     // this is a grenade and it's past its use-by date
  89.     self.think = GrenadeExplode;
  90.     self.nextthink = time + 0.1;
  91.   }
  92.   else
  93.   if (self.duration < time)
  94.     self.think = SUB_Remove;
  95.   else
  96.   {
  97.     self.nextthink = time + 0.1;
  98.  
  99.     v1 = self.origin;
  100.     v2 = v1;
  101.     traceline (v1, v2, TRUE, self);
  102.  
  103.     if (trace_inwater == TRUE) 
  104.     {
  105.       if ((random() > 0.72) && (self.classname == "rocket"))
  106.         CN_Missile_Bubbles(1);
  107.  
  108.       if (self.jump_flag == FALSE)
  109.       {
  110.         // correct velocity underwater if not underwater
  111.         // (jump_flag) already.
  112.         self.jump_flag = TRUE;  // now in water
  113.         self.swim_flag = TRUE;  // water->air transition not done
  114.         self.velocity = self.velocity * 0.4292;
  115.         self.angles = vectoangles(self.velocity);
  116.       }
  117.     }
  118.     else
  119.     {
  120.       // make sure we only do this for 1 water/surf transition
  121.       if (self.swim_flag == TRUE) 
  122.       {
  123.         if (self.classname == "rocket")
  124.         {
  125.           // correct velocity out of water for rockets
  126.           self.velocity = self.velocity * 2.33;
  127.         }
  128.         self.jump_flag = FALSE;  //out of water
  129.         self.swim_flag = FALSE;  //water->air transition finished
  130.       }
  131.     }
  132.   }
  133.   
  134. };
  135.  
  136. /*------------------------CN_Ditch_Rockets---------------------------
  137. Removes half your rockets, places them in a backpack and ejects
  138. it to the world.  You'll need this for when you get too many rockets
  139. and get weighed down.
  140. --------------------------------------------------------------------*/
  141. void() CN_Ditch_Rockets =
  142. {
  143.         local entity back_pack;
  144.         local float  num_to_ditch;  
  145.  
  146.         // if we have none or one then return!
  147.         if (self.ammo_rockets < 2)
  148.           return;
  149.  
  150.         // spawn a backpack
  151.         back_pack = spawn();
  152.  
  153.         // calculate number to ditch and set appropriate amounts
  154.         // for entity and backpack
  155.         num_to_ditch = self.ammo_rockets / 2;
  156.         num_to_ditch = floor(num_to_ditch);
  157.         back_pack.ammo_rockets = num_to_ditch;
  158.         self.ammo_rockets = self.ammo_rockets - num_to_ditch;
  159.  
  160.  
  161.         back_pack.owner = self;
  162.         makevectors(self.v_angle);
  163.         setorigin(back_pack, self.origin + '0 0 45');
  164.         back_pack.velocity = aim(self, 1000);
  165.         back_pack.velocity_x = back_pack.velocity_x * -340;
  166.         back_pack.velocity_y = back_pack.velocity_y * -340;
  167.         back_pack.velocity_z = back_pack.velocity_z * 380;
  168.         back_pack.angles = vectoangles(back_pack.velocity);
  169.         back_pack.flags = FL_ITEM;
  170.         back_pack.solid = SOLID_TRIGGER;
  171.         back_pack.movetype = MOVETYPE_TOSS;
  172.         back_pack.nextthink = time + 0.2;
  173.  
  174.         setmodel (back_pack, "progs/backpack.mdl");
  175.         setsize(back_pack, '-16 -16 0', '16 16 56');
  176.         back_pack.touch = BackpackTouch;
  177.         back_pack.nextthink = time + 120;    // remove pack after 120 secs
  178.         back_pack.think = SUB_Remove;
  179.  
  180.         sprint(self, "Dumped Rockets\n");
  181.  
  182.         W_SetCurrentAmmo();
  183. };
  184.  
  185. /*--------------------CN_Client_Init_Think---------------------------
  186. Startup messages
  187. --------------------------------------------------------------------*/
  188. void() CN_Client_Init_Think =
  189. {
  190.   sprint (self, "Realistic Weapons Mod by C. Newham (w_australia)\n");
  191.   sprint (self, "Version 1.2\n");
  192.   sprint (self, "* weapons unreliable\n");
  193.   sprint (self, "* rockets add weight\n");
  194.   sprint (self, "* recoil effects\n");
  195.   sprint (self, "* 200pc health speed increase\n");
  196.   sprint (self, "* impulse 20 - dump rockets\n");
  197. };
  198.